t=0:0.0005:0.5;
a1=0.8;a2=0.3;a3=0.1;
phi1=0;phi2=pi/4;phi3=pi/2;
x=a1*sin(2*pi*30*t+phi1)+a2*sin(2*pi*110*t+phi2)+a3*sin(2*pi*260*t+phi3);
y=x+2*randn(size(t));
figure(1)
plot(y(1:50))
title('时间序列图像')
xlabel('Frequency(Hz)')
Y= fft(y,256);
Pyy =Y.*conj(Y)/256;
f=1000/256*(0:127);
figure(2)
plot(f,Pyy(1:128))
title('频谱图')
xlabel('Frequency(Hz)')